#ifndef GAMEENGINE_MAPS_MAP_H
#define GAMEENGINE_MAPS_MAP_H

#include <GameEngine/Maps/maps_settings.h>

#include <GameEngine/Maps/terrain_descriptor.h>
#include <GameEngine/Geometry/Surfaces/parallelogram2d.h>



#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif


//=================================================================================


//! Base class for map representation
/*!
 *  The Map class defines the set of terrains associated to the map, and the bounding box
 *  that encloses the spatial domain in which the map lies.
 *
 *  The Map class also holds an array of cells. The order in which the cells are arranged
 *  depends on the type of map, and is deferred to the derived classes.
 */
class _Maps_decl Map {

public:
	//! Typedef used to handle map size
	typedef unsigned int MapSize;
	//! Typedef used to handle map indexes
	typedef MapSize MapIndex;
	//! Typedef used to handle cell indexes
	typedef unsigned int CellIndex;

public:
	Map(MapSize width, MapSize height);
	virtual ~Map();

	MapSize width() const;
	MapSize height() const;

	Parallelogram2d<float>& map_box();
	const Parallelogram2d<float>& map_box() const;

	TerrainManager& terrains();
	const TerrainManager& terrains() const;

	Point2d<float> global_to_local_coordinates(const Point2d<float>& rhs) const;
	Point2d<float> local_to_global_coordinates(const Point2d<float>& rhs) const;

	CellIndex get_array_index(MapIndex x, MapIndex y) const;
	bool get_axes_indexes(MapIndex& x, MapIndex& y, CellIndex index) const;

protected:
	//! Terrains managed by the map
	TerrainManager terrains_;

	//! Cell size
	Parallelogram2d<float> map_box_;

	//! Width of the map
	MapSize width_;
	//! Height of the map
	MapSize height_;
};


//=================================================================================


#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#endif
